import request from '../utils/request';

export const fetchData = query => {
    return request({
        url: './table.json',
        method: 'get',
        params: query
    });
};
// 登录
export function login(query) {
  return request({
    url: '/user/login',
    method: 'post',
    data: query
  })
};
// 通过userId获取用户信息
export function getUserInfo(query){
	return request({
	  url: '/user/info',
	  method: 'get',
	  params: query
	})
};
// 通过userId获取用户信息
export function getUserList(query){
    return request({
        url: '/user/list',
        method: 'get',
        params: query
    })
};
// 通过userId获取种植园信息
export function getPlantationInfo(query){
    return request({
        url: '/plant/info',
        method: 'get',
        params: query
    })
};
// 通过plantationId获取种植园信息
export function getCropList(query){
    return request({
        url: '/crop/list',
        method: 'get',
        params: query
    })
};
// 通过plantationId获取种植园信息
export function getPlantationList(query){
    return request({
        url: '/plant/list',
        method: 'get',
        params: query
    })
};
// 获取农业知识列表
export function getKnowList(query){
    return request({
        url: '/crop/knowList',
        method: 'get',
        params: query
    })
};
// 添加经济作物不良信息
export function addCropAdverse(data){
    return request({
        url: '/adverse/add',
        method: 'post',
        data: data
    })
};
// 添加经济作物信息
export function addCrop(data){
    return request({
        url: '/crop/add',
        method: 'post',
        data: data
    })
};
// 修改经济作物信息
export function addCrop(data){
    return request({
        url: '/crop/edit',
        method: 'post',
        data: data
    })
};
// 添加用户信息
export function addUser(data){
    return request({
        url: '/user/add',
        method: 'post',
        data: data
    })
};
// 获取当前用户不良事件列表
export function getAdverseList(query) {
    return request({
        url: '/adverse/list',
        method: 'get',
        params: query
    })
}